import React, { Component } from 'react'
import './index.css';
export default class Header extends Component {
    render() {
        return (
            <div className="todo-header">
                <input type="text" placeholder="请输入你的任务名称，按回车键确认"
                 onKeyDown={this.add} />
            </div>
        )
    }

    add = (e) => {
        //检查是否为回车键
        if(e.keyCode === 13){
            //添加新的任务
            this.props.addTodo(e.target.value);
        }
    }
}
